import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SelectServlet extends HttpServlet{
	public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
	{
		
		String str1=req.getParameter("pid");
		//String str2=req.getParameter("ename");
		//String str3=req.getParameter("sal");
		//String str4=req.getParameter("deptno");
		int pid=Integer.parseInt(str1.trim());
	//	int sal=Integer.parseInt(str3.trim());
	//	int deptno=Integer.parseInt(str4.trim());
		
		HibernateDao hd=new HibernateDao();
		Object b=hd.select(pid);
		//System.out.println(b);
		Profile  p=(Profile )b;
		res.setContentType("text/html");
		PrintWriter pw=res.getWriter();
		
		if(p!=null)
		{
			pw.println("<table border='2'><tr><td>"+p.getPid()+"</td><td>"+p.getLaptop()+"</td><td>"+p.getCost()+"</td></tr></table>");
			
		}
		else
		{
			pw.println("<h1>record is not exist</h1>");
		}
			
		pw.println("<a href='profile.html'>HOME</a>");
	}
	}

